<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .erweima {
      width: 100px;
      height: 100px;
      background-color: #f40;
    }

    .hide {
      display: none;
    }

    .show {
      display: block;
    }
  </style>
</head>

<body>
  <button id="btn">按钮</button>
  <div class="erweima hide" id="er"></div>

  <script src="js/common.js"></script>
  <script>
    var er = my$("er");
    var btn = my$("btn");
    var flag = true;
    btn.onclick = function () {
      if (flag) {
        // 1.直接把所有className写出来 将hide换成show
        //er.className = "erweima show";

        // 2. 利用伪数组的特点，使用repalce替换
        er.className = er.className.replace("hide", "show");
        flag = false;
      } else {
        // 1.直接把所有className写出来 将hide换成show
        //er.className = "erweima show";

        // 2. 利用伪数组的特点，使用repalce替换
        er.className = er.className.replace("show", "hide");
        flag = true;
      }

    };

  </script>
</body>

</html>